/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ChatBoxPanel.java
 *
 * Created on 11/11/2011, 21:55:10
 */
package clientApp;

/**
 *
 * @author Gabriel
 */
@SuppressWarnings("serial")
public class ChatBoxPanel extends javax.swing.JPanel {

    /** Creates new form ChatBoxPanel */
    public ChatBoxPanel() {
        initComponents();
    }

    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTFChat = new javax.swing.JTextArea();

        jTFChat.setColumns(20);
        jTFChat.setEditable(false);
        jTFChat.setRows(5);
        jScrollPane1.setViewportView(jTFChat);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
        );
    }
    
    public void showChatMessage(String sender, String message) {
		if (!sender.isEmpty())
			sender += ": ";
		if (jTFChat.getText().isEmpty())
			jTFChat.setText(sender + message);
		else
			jTFChat.setText(jTFChat.getText() + "\n" + sender + message);
	}
    
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTFChat;
    // End of variables declaration//GEN-END:variables
}
